<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div>
        这是给JSONP插件用的一个通用的方法
    </div>
    <script>
        var keywords = [{
            keyword: 1,
            name: 'lys'
        },{
            keyword: 1,
            name: 'lys'
        }];
        function ToQueryStringParams (obj, objName) {
            var stringParams = '';
            if (Object.prototype.toString.call(obj) === '[object Array]') {

                obj.forEach(function (item, index) {
                    stringParams += Object.keys(item).map(function (key) {
                        let strKey = objName + '[' + index + '][' + key + ']';
                        return ''.concat(encodeURIComponent(strKey), '=').concat(encodeURIComponent(item[key])) + '&';
                    }).join('');
                });
            } else if (Object.prototype.toString.call(obj) === '[object Object]') {

            }
            return stringParams.slice(0, stringParams.length - 1);
        }
        ToQueryStringParams(keywords, 'keywords');
    </script>
</body>
</html>